package com.star.book.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import com.google.common.collect.Maps;
import com.star.book.entity.LoginInfo;
import com.star.book.mapper.LoginInfoMapper;
import com.star.book.service.ILoginInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author Mr Kong
 * @since 2020-10-03
 */
@Service
public class LoginInfoServiceImpl extends ServiceImpl<LoginInfoMapper, LoginInfo> implements ILoginInfoService {
    @Autowired
    private ILoginInfoService loginInfoService;
    @Override
    public List<LoginInfo> findByPage(Integer id) {
        return baseMapper.findByPage(id);
    }

    @Override
    public Map<String, Object> loginInfo(Integer id) {
        Map<String, Object> loginUser = Maps.newHashMap();
        List<LoginInfo> list = loginInfoService.list();
        int loginInfoTotalCount = list.size();
        Integer page ;
        if(loginInfoTotalCount == 0 || loginInfoTotalCount < 0){
            page = 0;
        }else{
            page = loginInfoTotalCount / 10;
            if(loginInfoTotalCount % 10 > 0){
                page=page+1;
            }
        }
        loginUser.put("page",page);
        List<LoginInfo> byPage = baseMapper.findByPage(id);
        loginUser.put("loginUser",byPage);
        return loginUser;
    }
}
